<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/share/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>序号列表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<%@ include file="/WEB-INF/share/easyuilist.jsp"%>
    <script type="text/javascript">
	    $(function () {
	        InitialPage();
	        GetGrid();
	        
	        $('#status').ComboBox({
				description : "==请选择==",
				isuse : true
			})
	    });
	    //初始化页面
	    function InitialPage() {
	        //resize重设(表格、树形)宽高
	        $(window).resize(function (e) {
	            window.setTimeout(function () {
	                $('#gridTable').setGridWidth(($('.gridPanel').width()));
	                $("#gridTable").setGridHeight($(window).height() - 136.5);
	            }, 200);
	            e.stopPropagation();
	        });
	    }
	    //加载表格
	    function GetGrid() {
	        var selectedRowIndex = 0;
	        var $gridTable = $('#gridTable');
	        $gridTable.jqGrid({
	            url: "${ctx}/agentxh/getdata?agentid=${agentid}",
	            datatype: "json",
	            height: $(window).height() - 136.5,
	            autowidth: true,
	            colModel: [
	                { label: '主键', name: 'id', hidden: true },
	                { label: '序号', name: 'num', index: 'num', width: 140, align: 'left' },
	                { label: '价格', name: 'money', index: 'money', width: 100, align: 'left',
	                	formatter: function (cellvalue, options, rowObject) {
                        return cellvalue+'元';
                    } },
	                { label: '使用次数', name: 'usecount', index: 'money', width: 100, align: 'left',
	                	formatter: function (cellvalue, options, rowObject) {
                        return cellvalue;
                    } },
	                { label: '使用天数', name: 'usetime', index: 'money', width: 100, align: 'left',
	                	formatter: function (cellvalue, options, rowObject) {
                        return cellvalue;
                    } },
	                {
	                    label: "状态", name: "status", index: "isuse", width: 100, align: "center",
	                    formatter: function (cellvalue, options, rowObject) {
	                        if (cellvalue == 1) {
	                            return '已销售';
	                        }
	                        else if(cellvalue==2)return '已激活';
	                    }
	                },
	                { label: "生成时间", name: "addtime", index: "addtime", width: 140, align: "left" },
	                { label: "", name: "", index: "", width: 10, align: "left" }
	            ],
	            viewrecords: true,
	            rowNum: 20,
	            rowList: [20,30, 50, 100],
	            pager: "#gridPager",
	            rownumbers: true,
	            shrinkToFit: false,
	            gridview: true,
	            onSelectRow: function () {
	                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
	            },
	            gridComplete: function () {
	                $("#" + this.id).setSelection(selectedRowIndex, false);
	            }
	        });
	        //查询事件
	        $("#btn_Search").click(function () {
	            var queryJson = {
	                status: $("#status").attr('data-value')
	            }
	            $gridTable.jqGrid('setGridParam', {
	                postData: queryJson, page: 1
	            }).trigger('reloadGrid');
	        });
	        //查询回车
	        $('#txt_Keyword').bind('keypress', function (event) {
	            if (event.keyCode == "13") {
	                $('#btn_Search').trigger("click");
	            }
	        });
	    }
	    
	</script>
</head>
<body class="mybody">
	<div class="titlePanel">
	    <div class="title-search">
	        <table>
	            <tr>
	                <td>
					状态:
	                <td>
	                    <div id="status" type="select" class="ui-select ui-underline" style="width:200px;" isvalid="yes" checkexpession="NotNull">
								<ul>
									<li data-value="1">已销售</li>
									<li data-value="2">已激活</li>
								</ul>
							</div>
	                </td>
	                <td style="padding-left: 5px;">
	                    <a id="btn_Search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;查询</a>
	                </td>
	            </tr>
	        </table>
	    </div>
	    <div class="toolbar">
	        <div class="btn-group">
	            <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
	        </div>
	    </div>
	</div>
	<div class="gridPanel">
	    <table id="gridTable"></table>
	    <div id="gridPager"></div>
	</div>
</body>
</html>
